unit caozuowenjian;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, leixing_changliang;

procedure chuangjian_wenjian(pwenjian: pwenjian_leixing;
  wenjian_lujing: zichuan_leixing);
function dakai_wenjian(pwenjian: pwenjian_leixing;
  wenjian_lujing: zichuan_leixing): integer;
procedure guanbi_wenjian(pwenjian: pwenjian_leixing);
procedure xieru_wenjian(pwenjian: pwenjian_leixing; zichuan: zichuan_leixing);
function shifoujiewei_wenjian(pwenjian: pwenjian_leixing): boolean;

implementation

procedure chuangjian_wenjian(pwenjian: pwenjian_leixing;
  wenjian_lujing: zichuan_leixing);
begin
  system.Assign(pwenjian^, wenjian_lujing);
  system.Rewrite(pwenjian^);
end;

function dakai_wenjian(pwenjian: pwenjian_leixing;
  wenjian_lujing: zichuan_leixing): integer;
begin
  if FileExists(wenjian_lujing) then
  begin
    system.Assign(pwenjian^, wenjian_lujing);
    Result := chenggong_changliang;
  end
  else
  begin
    Result := buchenggong_changliang;
  end;
end;

procedure guanbi_wenjian(pwenjian: pwenjian_leixing);
begin
  if pwenjian <> nil then
  begin
    system.Close(pwenjian^);
  end;
end;

procedure xieru_wenjian(pwenjian: pwenjian_leixing; zichuan: zichuan_leixing);
begin
  WriteLn(pwenjian^, zichuan);
end;

function shifoujiewei_wenjian(pwenjian: pwenjian_leixing): boolean;
begin
  Result := system.EOF(pwenjian^);
end;

end.
